﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using IrisGenerator.Common.Core;
using System.Windows.Forms;
using IrisGenerator.Common.UI.XmlConfiguration;
using IrisGenerator.Common.Core.UI;
using IrisGenerator.Common.DataTypes;
using IrisGenerator.Framework.Reflection;
using IrisGenerator.Framework.UI.Controls;

namespace IrisGenerator.Common.UI.Controls.DataGrids
{
    [Serializable()]
    public class MetatypeEquivalenceDataGrid:BindableDataGrid<MetatypeEquivalences>
    {
       
        public MetatypeEquivalenceDataGrid()
            : base()
        {
            this.SourceMethod = new MethodCall();

            this.SourceMethod.MethodName = "Select_METATYPE_EQUIVALENCES_By_TAR_ID";
            this.SourceMethod.TypeName = "IrisGenerator.Common.DataTypes.MetatypeEquivalences";
            this.BindingType = "IrisGenerator.Common.Core.ConnectedCollectionBase`1";

            InitializeGrid();
        }


        public string ConfigFileName { get; set; }
        public string ConfigFileSection { get; set; }

        private void InitializeGrid()
        {
            this.Name = "MetatypeEquivalences";
            this.AutoGenerateColumns = false;
            
            XmlConfigFileReader.ConfigFilePath = @"C:\Personnel\Developpement\Code Generator 2008\IrisGenerator\IrisGenerator.Common\ControlsConfigFile.xml";
            XmlConfiguration.XmlConfigFileReader.LoadConfiguration(this);
        }

        private Target _currentTarget;
        public Target CurrentTarget
        {
            get
            {
                return _currentTarget;
            }
            set
            {
                this._currentTarget = value;
                this.SetCurrentTarget(value);
            }
        }

        private void SetCurrentTarget(Target value)
        {
            if (this.SourceMethod != null && value!=null)
            {
                this.SourceMethod.Parameters.Clear();
                this.SourceMethod.Parameters.Add(new MethodCallParameter("TAR_ID", value.TarId));
                this.LoadSource();
            }
        }

        protected override void SetMessageHandler()
        {
            
        }
    }
}
